package com.pony.iphone.controller;

import com.alibaba.fastjson.JSON;
import com.pony.iphone.dto.QuestionAnswerDto;
import com.pony.iphone.utils.AppHttpCodeEnum;
import com.pony.iphone.utils.R;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.nio.file.Files;
import java.util.List;

/**
 * @author pony
 * @version 1.0
 * @description: powershell测试
 * @create 2025/9/02 14:46
 */
@RestController
@RequestMapping("powershell")
public class PowerShellController {
    @GetMapping("/test")
    @ResponseBody
    public String test(){
        try {
            // 从resources/static/powershell/download.ps1读取文件内容
            Resource resource = new ClassPathResource("static/powershell/download.ps1");
            return new String(Files.readAllBytes(resource.getFile().toPath()));
        } catch (IOException e) {
            e.printStackTrace();
            return "Error reading PowerShell script";
        }
    }
}
